﻿using UnityEngine;

namespace PnFramework.Unity
{
    public class MonoKit : MonoBehaviour
    {
        private static MonoKit mono;
        public static MonoKit Ins
        {
            get
            {
                if (mono == null)
                {
                    var o = new GameObject(nameof(MonoKit));
                    mono = o.AddComponent<MonoKit>();
                }                   
                return mono;
            }
        }

        public const string OnUpdate = "OnUpdate";
        public const string OnFixedUpdate = "OnFixedUpdate";
        public const string OnLateUpdate = "OnLateUpdate";

        private void Awake() => GameObject.DontDestroyOnLoad(gameObject);
        private void Update() => EventMgr.Instance.Trigger(OnUpdate);
        private void FixedUpdate() => EventMgr.Instance.Trigger(OnFixedUpdate);
        private void LateUpdate() => EventMgr.Instance.Trigger(OnLateUpdate);
    }
}